package com.platform.modules.acme.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.platform.common.utils.Constant;
import com.platform.common.utils.RestResponse;
import com.platform.common.utils.ShiroUtils;
import com.platform.modules.acme.entity.AcmeOrderEntity;
import com.platform.modules.acme.service.AcmeOrderService;
import com.platform.modules.sys.controller.AbstractController;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @author DavenTsang
 */
@RestController
@RequestMapping("/acme/order")
public class AcmeOrderController extends AbstractController {

    @Autowired
    AcmeOrderService acmeOrderService;


    @GetMapping("/list")
    @RequiresPermissions("acme:order:list")
    public RestResponse list(Map<String,Object> params) {
        if (!Constant.SUPER_ADMIN.equals(getUserId())) {
            //不是超级管理员查询自己的即可
            params.put("member_id", getUserId());
        }
        Page<AcmeOrderEntity> page = acmeOrderService.queryPage(params);
        return RestResponse.success().put("page", page);
    }

}
